package com.example.javaquest;

public class Main {

	static SimpleBotTutorial bs = new SimpleBotTutorial();
    static boolean keepOn = true;

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		String comname = "COM3"; 
		int baud = 115200;
		
		if(args.length > 0)
		{
			try{
				comname = args[0].toString();
				baud = Integer.parseInt(args[1]);
				
			}catch(Exception ex){
				System.out.println("Could not parse args, using defaults. Use COM3 115200 as args: " + ex.getMessage());
				comname = "COM3"; 
				baud = 115200;
			}
		}
		System.out.println("Starting on: " + comname  + " baud: " + baud);
		while(!bs.startBot(comname,baud))
		{
			System.out.println("Could not start bot will retry");
			try {
				Thread.sleep(20000);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		
		while(keepOn)
		{
			if(bs.botConnected)
			{
				bs.printAllBotValues();
				try {
					Thread.sleep(5000);
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}else{
				try {
					Thread.sleep(10000);
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}

	}
	

	

}
